<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link href="style/css/style.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="style/js/jquery-1.4.2.min.js"></script>
<script type="text/javascript" src="style/js/fun.js"></script>
</head>

<body>
<span class="subTitle">移动数组指针</span>
<?php
	$array_1 = array("1","3","5","4","7","2","6");
	echo "当前指针(current方法)所指向的位置".current($array_1);
	echo "<br />当前指针(pos方法)所指向的位置".pos($array_1);
?>
<span class="subTitle">数组指针的移动</span>
<?php
	$array_1 = array("1","3","5","4","7","2","6");
	echo "原始数组为: ";
	for($i = 0; $i < count($array_1); $i++){
		echo $array_1[$i]." ";
	}

	echo "<br />当前指针位置: ".current($array_1);
	echo "<br />指针向后移动一位: ".next($array_1);
	echo "<br />指针移动至数组末尾: ".end($array_1);
	echo "<br />指针向前移动一位: ".prev($array_1);
	
	echo "<br />使用foreach处理, 打印原始数组: ";
	foreach($array_1 as $test){
		echo $test." ";
	}
?>
<span class="subTitle">移去数组中重复的值</span>
<?php
	error_reporting(0);
	$array_2 = array("1","3","2","4","1","5","3","2","7");
	
	echo "原始数组为: ";
	for($i = 0; $i < count($array_2); $i++){
		echo "[".$array_2[$i]."] ";
	}

	$new_array = array_unique($array_2);
	echo "<br />去除重复的值以后, 数组为: <br />";
	print_r($new_array);
	/*for($i = 0; $i < count($new_array); $i++){
		echo "[".$new_array[$i]."] ";
	}*/
?>
<span class="subTitle">计算数组中元素出现的次数</span>
<?php
	$array_3 = array("2","1","2","3","6","1","3","8","7");
	
	echo "原始数组为: ";
	for($i = 0; $i < count($array_3); $i++){
		echo $array_3[$i]." ";
	}

	$temp = array_count_values($array_3);
	
	echo "<br />经过统计以后个元素出现的次数: <br />";
	print_r($temp);
	/*for($j = 0; $j < count($temp); $j++){
		echo $temp[$j]." ";
	}*/
?>
<span class="subTitle">合并数组</span>
<?php
	$array_4 = array("1","2","3");
	$array_5 = array("3","5","6");
	
	echo "原始数组1为: ";
	for($i = 0; $i < count($array_4); $i++){
		echo $array_4[$i]." ";
	}
	echo "<br />原始数组2为: ";
	for($i = 0; $i < count($array_5); $i++){
		echo $array_5[$i]." ";
	}
	
	$new_array = array_merge($array_4,$array_5);
	echo "<br />合并以后的新数组: ";
	for($i = 0; $i < count($new_array); $i++){
		echo $new_array[$i]." ";
	}
?>
</body>
</html>